package cn.edu.zjut.mina.bean;

public class MyAppInfo {
	public static final String APP_ID = "wx47e2111defd77e54";
	public static final String SERECT = "aa93e6213f825ca0e0aa44b6600fdccf";
	
	/**
	 * 获取access_token的url
	 * @param code
	 * @return url
	 */
	public static String getAccess_tokenUrl (String code) {
		String url = "https://api.weixin.qq.com/sns/oauth2/access_token?" +
		        "appid=" + APP_ID +
		        "&secret=" + SERECT +
		        "&code=" + code +
		        "&grant_type=authorization_code";
		return url;
	}
	
	/**
	 * 获取用户信息的url
	 * @param access_token
	 * @param openid
	 * @return url
	 */
	public static String getUserInfoUrl (String access_token, String openid) {
		String url = "https://api.weixin.qq.com/sns/userinfo?access_token=" + access_token +
                "&openid=" + openid;
		return url;
	}
	
	/**
	 * 刷新access_token的url
	 * 返回结果例子:
	 * {"openid":"oPk8mwL5bys2ZMP2A7CAmE2242gs","access_token":"6vWkok_rgVzXOKZR-oLmAkZ7dqm5fLsC9NGKiG0Tp1eNhqMAIPGuvsUAhL1G-sco6iQRwgu_CQSirb_7UkN10V9BeO1aYEdPDJBDHwtMRQ4","expires_in":7200,"refresh_token":"Rn5u0tH_eWF27qKIHegMfIrqC0vJikDPPdg9-iDr3liZQj0CnfM3Xm8NWojC99D0vOLpRMqVNQSlJ2uEdmXuo9GbZZ8NKDeIudtH6r_7Uc0","scope":"snsapi_base,snsapi_userinfo,"}
	 * @param refresh_token
	 * @return
	 */
	public static String getRefreshAccess_tokenUrl(String refresh_token) {
		String url = "https://api.weixin.qq.com/sns/oauth2/refresh_token?appid=" + APP_ID + 
				"&grant_type=refresh_token&refresh_token=" + refresh_token;
		return url;
	}
	
	/**
	 * 判断access_token是否有效
	 * 返回例子:{"errcode":0,"errmsg":"ok"}
	 * @param access_token
	 * @param openid
	 * @return
	 */
	public static String getAccess_token_validurl(String access_token, String openid) {
		String url = "https://api.weixin.qq.com/sns/auth?access_token=" + access_token + "&openid=" + openid;
		return url;
	}
}
